<?php
	class template {
		private $title = "Monster Ministries";
		private $js = array();
		private $css = array();
		private $tabs = array();
		private $subMenus = array();
		private $account;
		private $database;
		private $selectedTab = 0;
		private $selectedSub = -1;
		private $showCal = false;
		private $info = "";
		
		//Will be used to set the title of the page before the page is generated
		public function setTitle($newTitle) {
			$this->title = $newTitle;
		}
		
		//Page displayer changer
		public function currentPage($info) {
			$this->info = htmlentities($info);
		}
		
		//Hide the calendar
		public function hideCal() {
			$this->showCal = false;
		}
		
		//Show the calendar
		public function showCal(){
			$this->showCal = true;
		}
		
		//Set the tab and the sub tab
		public function setTab($tab, $subtab = -1) {
			$this->selectedTab = $tab;
			$this->selectedSub = $subtab;
		}
		
		//Add a tab to the page
		public function addTab($tabName, $link = "#") {
			$this->tabs[] = array($tabName, $link);
		}
		
		//Add a submenu to the page
		public function addSubMenu($subName, $link = "#") {
			$this->subMenus[] = array($subName, $link);
		}
		
		//Will be used to add Javascript to a page before the page is generated
		public function addJS($newJS) {
			$this->js[] = $newJS;
		}
		
		//Will be used to generate the page
		public function generate() {
			//Do stuff here
			print "<";
			print "?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?";
			print ">\n";
			$contents = eval("?>".file_get_contents($_SERVER['DOCUMENT_ROOT']."/template/header.php"));
			print $contents;
		}
	
		//Will be used to add CSS to a page before the page is generated    
		public function addCSS($newCSS) {
			$this->css[] = $newCSS;
		}
		
		//Will be ran on the construction of the class
		public function __construct($account, $database) {
			$this->account = $account;
			$this->database = $database;
			//Add the tabs!
			$this->addTab("HOME", "index.php");
			$this->addTab("EVENTS", "events.php");
			$this->addTab("PRAYER", "prayer.php");
			$this->addTab("MEDIA", "media.php");
			$this->addTab("SPONSORS", "sponsors.php");
			$this->addTab("ESTORE", "estore.php");
			$this->addTab("DONATE", "donate.php");
			$this->addTab("ABOUT US", "about.html");
			if($account->isLogged()) $this->addTab("SCRIPTURE", "scripture.php");
			$this->addTab("ACCOUNT", "account.php");
		}
		
		//Will be used to generate the footer of the page when the class dies
		public function __destruct() {
			//Function is ran automatically when the class dies
			$contents = eval("?>".file_get_contents($_SERVER['DOCUMENT_ROOT']."/template/footer.php"));
			print $contents;
		}
	}
?>